package admintool;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.util.prefs.Preferences;

/**
 * 
 * @author Administrator
 */
public class AccessTokenRegistry {
	
    /**
     * 
     */
    public static void updateUserPrefs() {
		try {
			Preferences userPrefs = Preferences.userRoot();
			if (!userPrefs.nodeExists("com/google/cloud/sqlservice")) {
				InputStream is = new BufferedInputStream(AccessTokenRegistry.class.getResourceAsStream("/admintool/resources/accessToken.xml"));
				Preferences.importPreferences(is);
				userPrefs.flush();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	

        /**
         * 
         * @throws Exception
         */
        public static void outputUserPrefs() throws Exception {
		Preferences userPref = Preferences.userRoot();
		userPref.node("com/google/cloud/sqlservice").exportSubtree(System.out);
	}
}
